/*
 * HexTile.java
 *
 * Created on November 18, 2007, 12:43 PM
 *
 * Copyright (C) 2007-2008  Hylke van der Schaaf
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, in version 3 of the License.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
package hextd.hex;

import com.usoog.tdcore.gamegrid.GameGrid;
import com.usoog.tdcore.gamegrid.GridPoint;
import com.usoog.tdcore.player.Player;
import com.usoog.tdcore.tile.AbstractTile;

/**
 *
 * @author hylke
 */
public abstract class HexTile extends AbstractTile {

	public HexTile(GameGrid grid) {
		super(grid);
	}
	/**
	 * a hex with a radius (distance center-point) of 1 will have this as 
	 * half-width (distance center-side).
	 */
	public static final double relativeHexWidth = Math.sin(Math.PI / 3.0);

	public static enum HexType {

		base,
		baseTransparent,
		empty,
		path
	}

	public static enum Neighbour {

		right, left, rightUp, leftUp, rightDown, leftDown;
	}

	public static enum HighlightType {

		none,
		selectTower,
		placeTower,
		editHex;
	}

	public static GridPoint getNeightbourOf(GridPoint location, Neighbour direction) {
		GridPoint target = null;
		switch (direction) {
			case left:
				target = new GridPoint(
						location.col - 1,
						location.row);
				break;
			case leftDown:
				target = new GridPoint(
						location.col - ((location.row + 1) & 1),
						location.row + 1);
				break;
			case leftUp:
				target = new GridPoint(
						location.col - ((location.row + 1) & 1),
						location.row - 1);
				break;
			case right:
				target = new GridPoint(
						location.col + 1,
						location.row);
				break;
			case rightDown:
				target = new GridPoint(
						location.col + (location.row & 1),
						location.row + 1);
				break;
			case rightUp:
				target = new GridPoint(
						location.col + (location.row & 1),
						location.row - 1);
				break;
		}
		return target;
	}

	abstract public char getShortName();

	abstract public void initNeighbours();

	abstract public void setHighlight(HighlightType hightlight);

	abstract public void setHighlightRange(float range);

	abstract public void addClaim(Player player, int level);

	abstract public void addClaim(Player player, int level, int radius);
}
